package com.qqtop10.manager.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qqtop10.manager.model.PagingArgs;
import com.qqtop10.manager.model.temp.Goods;
import com.qqtop10.manager.service.GoodsService;
import com.qqtop10.manager.utils.Result;

@Controller
@RequestMapping("/manager/qqg/")
public class QQGGoodsController extends BaseController {
	
	@Autowired
	@Qualifier("goodsService")
	private GoodsService goodsService;
	

	@RequestMapping("getAllQQGGoods.do")
	@ResponseBody
	public com.qqtop10.manager.model.Result getAllQQGGoods() {
		PagingArgs pagingArgs = getPagingArgs();
		List<Goods> goodsList = goodsService.getAllQQGGoods(pagingArgs);
		return page(goodsService.allQQGGoodsCount(), goodsList);
	}

	@RequestMapping("updateQQGBoutique.do")
	@ResponseBody
	public Result updateQQGBoutique(String uuid, Boolean isBoutique) {
		Map<String, Object> map = new HashMap<>();
		Result result = new Result();
		map.put("uuid", uuid);
		map.put("qqgBoutique", isBoutique);
		int res = goodsService.qqgBoutiqueByGoodsUuid(map);
		if (res > 0) {
			result.setCode(1);
			result.setMsg("操作成功");
		} else {
			result.setCode(99);
			result.setMsg("操作失败");
		}
		return result;
	}

}
